const path = "https://api-hmugo-web.itheima.net/api/public/v1"
let num = 0;
export const request = (params) => {
  return new Promise((resolve, reject) => {
    num++;
    wx.showLoading({
      title: '正在加载',
      mask:true
    })
    wx.request({
      ...params,
      url: path + params.url,
      success: (res) => {
        resolve(res)
      },
      fail: (err) => {
        reject(err)
      },
      complete: () => {
        num--;
        if (num === 0) { 
          wx.hideLoading()
        }
      }
    })
  })
}
